package com.jiepos.mpos.biz.channel.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

import com.jiepos.mpos.biz.channel.service.TransLimitService;
import com.jiepos.mpos.common.entity.App_Trans_LimitEntity;
import com.jiepos.mpos.core.controller.BaseController;
import com.jiepos.mpos.core.entity.Pagination;

/**
 * 
 * 
 * <p>标题: —— 交易限额表控制器</p>
 * <p>模块: 通用平台</p>
 * <p>版权: Copyright (c) 2017 江苏杰博实信息技术有限公司
 * @ProjectName:  [mpos] 
 * @Package com.jiepos.mpos.biz.channel.controller 
 * @author 张学涛
 * @version 1.0
 * @since 2017年9月30日上午11:00:42
 * @history（历次修订内容、修订人、修订时间等）
 */
@Controller
@RequestMapping("translimit")
public class TransLimitController extends BaseController {
	
	@Autowired
	private TransLimitService transLimitService;
	
	/**
	 * 进入交易限额列表页面
	 * @param request
	 * @param response
	 * @param pagination
	 * @return
	 */
	@RequestMapping("/getTransLimitList.do")
	public ModelAndView getTransLimitList(HttpServletRequest request,HttpServletResponse response,Pagination pagination){
		ModelAndView model=new ModelAndView("/module/channel/translimit/translimit_list");
		return super.getDetail(request, response, model);
	}
	
	/**
	 * 查询交易限额列表信息json数据
	 * @param pagination
	 * @param transLimit
	 * @return
	 */
	@RequestMapping("/getTransLimitListJson.do")
	public @ResponseBody Map getTransLimitListJson(Pagination pagination,App_Trans_LimitEntity transLimit){
		return transLimitService.getTransLimitList(pagination, transLimit);
	}
	
	/**
	 * 进入交易限额信息详细页面
	 * @param request
	 * @param response
	 * @param pagination
	 * @param limit_uuid
	 * @return
	 */
	@RequestMapping("/getTransLimitDetail.do")
	public ModelAndView getTransLimitDetail(HttpServletRequest request, HttpServletResponse response,
			Pagination pagination,String limit_uuid){
		ModelAndView model=new ModelAndView("/module/channel/translimit/translimit_detail");
		Map transLimit=transLimitService.getTransLimitById(limit_uuid);
		model.addObject("transLimit", transLimit);		
		return super.getDetail(request, response, model);
	}
	
	/**
	 * 保存交易限额
	 * @param request
	 * @param response
	 * @param transLimit
	 * @return
	 */
	@RequestMapping("/saveTransLimit.do")
	public ModelAndView saveTransLimit(HttpServletRequest request, HttpServletResponse response,App_Trans_LimitEntity transLimit){
		System.out.println(transLimit.getLimit_uuid()+"=="+transLimit.getChannel_no()+"=="+transLimit.getLimit_type()+"=="+transLimit.getLimit_idx()+"=="+transLimit.getLimit_amount()+"=="+transLimit.getTrans_amount()+"=="+transLimit.getBegdate()+"=="+transLimit.getEnddate()+"=="+transLimit.getBegtime()+"=="+transLimit.getEndtime()+"=="+transLimit.getTrans_date()+"=="+transLimit.getLimit_st());
		transLimitService.saveTransLimit(transLimit, super.getLoginUser(request, response));		
		Map map=super.getLoginUser(request, response);  
		return new ModelAndView(new RedirectView("getTransLimitList.do"), map);
	}
	
	/**
	 * 删除交易限额
	 * @param request
	 * @param response
	 * @param limit_uuids
	 * @return
	 */
	@RequestMapping("/deleteTransLimitByIds.do")
	public ModelAndView deleteTransLimitByIds(HttpServletRequest request, HttpServletResponse response,String limit_uuids){
		transLimitService.deleteTransLimitByIds(limit_uuids);
		Map map=super.getLoginUser(request, response);  
		return new ModelAndView(new RedirectView("getTransLimitList.do"), map);
	}
	
	/**
	 * 校验交易限额
	 * @param transLimit
	 * @return
	 */
	@RequestMapping("/checkTransLimit.do")
	public @ResponseBody String checkTransLimit(App_Trans_LimitEntity transLimit){		
		return transLimitService.checkTransLimit(transLimit);
	}

}
